/*****************************************************************************
 *
 * Copyright (C) 2003 CSHCN, University of Maryland.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Authors: Matthew Impett <m.impett@flarion.com>
 *
 *
 *****************************************************************************/

/**********************************************************************
   The following packet cache has been obtained from Matthew Impett's 
   TORA implementation code.....  
 **********************************************************************/

#ifndef MULTICAST_PACKET_CACHE_H
#define MULTICAST_PACKET_CACHE_H

#include "defs.h"

#define HASHBUCKETS             31   /* number of buckets for entries */
#define MAX_PACKET_CACHE        256   /* # of packets for each hash bucket */

/* This structure is used to hold a little cache of recently forwarded 
   packets which we can use to detect duplicate packets. */
struct pack_cache
{
        u_int32_t  	ip_src[MAX_PACKET_CACHE];
        u_int16_t	ip_id[MAX_PACKET_CACHE];
	u_int8_t	ip_hook[MAX_PACKET_CACHE];
	int		packet_cache_write_index;
};

struct pack_cache packet_cache[HASHBUCKETS];
void    init_packet_cache(void);
u_int8_t	packet_hashfunction(u_int32_t addr);
int		check_duplicate(u_int32_t source, u_int16_t id, 
    u_int8_t hook);

#endif /* MULTICAST_PACKET_CACHE_H */

